package SQL::Builder::Base::SubTypes;
use Moose;
use Moose::Util::TypeConstraints;

use SQL::Builder::Alias;
use SQL::Builder::Table;

# SUB-TYPES

# alias     
      subtype 'Alias'
            => as 'Object'
            => where { $_->isa('SQL::Builder::Alias') };
        
      coerce 'Alias'
            => from 'Str'
                => via { SQL::Builder::Alias->new( name => shift ) }; 
# table
      subtype 'Table'
            => as 'Object'
            => where { $_->isa('SQL::Builder::Table') };
            
      coerce 'Table'
            => from 'Str'
                  => via {
                        my @c = reverse( split /\./ , shift );
                        my @a = qw(table schema catalog);
                        my %h = map { $a[$_] => $c[$_] } 0 .. $#c;
                        SQL::Builder::Table->new( %h );
                  };

1;

=head1 NAME

SQL::Builder::Base::SubTypes - Common subtypes for Moose

=head1 SYNOPSIS

This is a base class that should be implemented by all SQL::Builder/SQL objects.
SQL::Builder::Base will hopefully provide useful
mechanisms and common interfaces to use and author SQL::Builder objects
quickly and easily.

=head2 USAGE SUMMARY

=head1 NOTES

This is a subclass of SQL::Builder::AnyObject, which defines many of the useful
methods which are documented in this class. That will change later...

=head1 SEE ALSO

SQL::Builder(3)
SQL::Builder::AnyObject(3)
